<?php

 require_once("../../../sqlconfig.php");

 mysql_connect($server, $sqlusr, $sqlpass) or die(mysql_error());
 mysql_select_db($mydb) or die(mysql_error()); 

 //Checks if there is a login cookie
 if(isset($_COOKIE["parentinformerprcshs"]) || isset($_COOKIE["parentinformerurcshs"])) { 
  if(isset($_COOKIE["parentinformerprcshs"])) {
   $username = $_COOKIE["parentinformerprcshs"]; 
  }
  else {
   $_SESSION['theerrcode'] = 2;
   header("Location: ../../logerr_atmpt.php");
  }
  $pass = $_COOKIE["parentinformerurcshs"];
  $check = mysql_query("SELECT * FROM logtbl WHERE usernm = '".$username."'") or die(mysql_error());
  while($info=mysql_fetch_array($check)) {
   if ($pass!=$info['pwrnd']) {
    $_SESSION['theerrcode'] = 2;
    header("Location: ../../logerr_atmpt.php");
   }
   else {

    if($info['priv']!=1) {
     header("Location: ../../");
    }
    else {
     header("Location: decisions.php");
    }

   }
  }
 }
?>